/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao.erp;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.erp.I_TimeStore;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.format.Formats;
import com.openbravo.bean.erp.TimeStore;
import com.openbravo.data.model.Field;

/**
 *
 * @author Administrator
 */
public class TimeStoreDAO extends BaseDAO<TimeStore> {

    public TimeStoreDAO(I_Session s) {
        super(s);
    }

    @Override
    public TableDefinition getTable() {
         return new TableDefinition(s,
                  "TIMESTORES",
                  new Field[]{
                       new Field(I_TimeStore.ID,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStore.NAME,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStore.CURDATE,Datas.TIMESTAMP,Formats.TIMESTAMP),
                       new Field(I_TimeStore.LOCATIONREF,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStore.CATEGORYREF,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStore.BUILDED,Datas.BOOLEAN,Formats.BOOLEAN)
                      },
                  new int[]{0});
    }

    @Override
    public void writeInsertValues(DataWrite dp, TimeStore obj) throws BasicException {
        dp.setString(1,obj.getID());
        dp.setString(2,obj.getName());
        dp.setTimestamp(3,obj.getCreateDate());
        dp.setString(4,obj.getLocationRef());
        dp.setString(5,obj.getProductCatRef());
        dp.setBoolean(6,obj.isIsBuiled());
    }

    public TimeStore readValues(DataRead dr,TimeStore obj) throws BasicException {
       if(obj==null)
    	   obj=new TimeStore();
       obj.setID(dr.getString(1));
       obj.setName(dr.getString(2));
       obj.setCreateDate(dr.getTimestamp(3));
       obj.setLocationRef(dr.getString(4));
       obj.setProductCatRef(dr.getString(5));
       obj.setIsBuiled(dr.getBoolean(6));
       return obj;
    }


    @Override
    public Class getSuportClass() {
        return TimeStore.class;
    }

}
